#include "transaction.h"
#include <iostream>

Transaction::Transaction(QString name, unsigned long long time)
    :m_timestamp(time)
    ,m_name(name)
    ,m_colum()
{
}

Transaction::Transaction(const Transaction& transaction)
    : m_timestamp(transaction.getTime())
    , m_name(transaction.getName())
    , m_colum(transaction.getColum())
{

}

Transaction & Transaction::operator=(const Transaction& transaction) {
    m_colum.clear();
    m_timestamp = transaction.getTime();
    m_name = transaction.getName();
    m_colum = transaction.getColum();

    return *this;
}

Transaction::Transaction()
    :m_timestamp(0)
    ,m_name("Empty")
    ,m_colum()
{

}

Transaction::~Transaction() {

}

void Transaction::appendColum(QString key, QString value) {
    m_colum.insert(key, value);
}

const Transaction::TypeTransColum & Transaction::getColum() const {
    return m_colum;
}

unsigned long long Transaction::getTime() const {
    return m_timestamp;
}

QString Transaction::getName() const {
    return m_name;
}

QString Transaction::findValueByColumName(const QString &columName, bool& found) const
{
    TypeTransColum::ConstIterator iter = m_colum.find(columName);
    if (iter != m_colum.constEnd()) {
        found = true;
        return iter.value();
    }
    else {
        found = false;
        return QString("");
    }
}
